<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>求字符串数组中每一项的长度</title>
</head>
<body>
    <script>
        let array = ['hello','w','', 'empty'];
        let newArray = [];
        //for循环遍历Array数组，并把每一项元素的长度赋值给newArray
        for(let i =0; i< array.length;i++){
            newArray[i]= array[i].length;
        }
        //输出newArray新数组
        console.log(newArray);
    </script>
</body>
</html>